package learning.socket;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class Socket1 {
	public static void main(String[] args) {
		try {
			Socket s = new Socket("127.0.0.1", 2222);
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
					s.getOutputStream()));
			while (true) {
				System.out.println("enter msg");
				bw.write(br.readLine());
				bw.newLine();
				bw.flush();
//				bw.close();
//				s.close();
			}
			// p();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	static void p(Object o) {
		System.out.println(o);
	}
}
